package com.riber.student.util;

import lombok.extern.slf4j.Slf4j;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: Riber
 * @date: 2022/10/28 16:40
 * @description:
 */
@Slf4j
public class DateUtil {
    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

    public static Date stringToDate(String date) {
        try {
            return sdf.parse(date);
        } catch (ParseException e) {
            //自定义报错信息 不用e.printStackTrace(); 2022/10/28 16:45
            log.info("日期格式化失败,返回固定值null");
            return null;
        }
    }
}
